import SwiftUI
import SPGlassKit

public struct GlassBannerExample: GlassExample {
    public static let componentID = "glass-banner"
    @State private var showsWarning = true
    @State private var retryCount = 0

    public init() {}

    public var body: some View {
        ScrollView {
            VStack(spacing: 12) {
                GlassBanner(.information, title: "Maintenance on Sunday", message: "The sample service will be read-only from 2:00 to 4:00.")
                GlassBanner(.success, title: "Payment received")
                if showsWarning {
                    GlassBanner(
                        .warning,
                        title: "Your card expires soon",
                        message: "Update your payment method before the end of the month to avoid an interruption.",
                        action: GlassBannerAction("Update card") { showsWarning = false },
                        onDismiss: { showsWarning = false }
                    )
                }
                GlassBanner(
                    .error,
                    verbatim: "Synchronisation failed (attempt \(retryCount + 1))",
                    message: "The server did not answer.",
                    action: GlassBannerAction("Retry") { retryCount += 1 }
                )
            }
            .padding()
        }
    }
}

#Preview("GlassBanner") { GlassBannerExample().glassTheme(.emerald) }
